package cn.jingzhuan.element.demo.view.util

import android.databinding.BindingAdapter
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import java.text.NumberFormat
import android.view.ViewGroup



/**
 * Created by Administrator on 2018/4/24.
 */
object DatabindingUtils {

//    @BindingConversion
//    fun convertColorToDrawable(color: Int): ColorDrawable {
//        return ColorDrawable(color)
//    }

    @JvmStatic
    @BindingAdapter("image")
    fun setImage(iv: ImageView, src: Int) {
        iv.setImageResource(src)
    }

    @JvmStatic
    @BindingAdapter("load_image")
    fun loadImage(imageView: ImageView, url: String?) = ImageLoader.loadImage(imageView, url)

    @JvmStatic
    @BindingAdapter("number_format","number_format_digit")
    fun formatNumber(textView: TextView, value:Int,digit :Int) {
        textView.text = UnitParseUtils.parseNumber(value,digit)
    }

    @BindingAdapter("load_blur_image")
    fun blurImage(view: ImageView, url: String?) {
        ImageLoader.loadBlurImage(view, url)
    }
}